package com.servlet.user;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.UserDao;
import com.entity.User;
import com.utils.TableUtils;
//列表数据
@WebServlet("/user/list")
public class UserListServlet extends HttpServlet{
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	//获取页数和每页条数，layui默认为10
	String page=req.getParameter("page");
	String limit=req.getParameter("limit");
	UserDao dao=new UserDao();
	//分页查询
	List<User> list=dao.findPageAll(Integer.parseInt(page), Integer.parseInt(limit));
	resp.getWriter().print(TableUtils.tablePageResult(list,dao.findAll().size()));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	super.doPost(req, resp);
    }
}
